<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>
          <i class="el-icon-lx-redpacket_fill"></i> {{ test }}
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <div class="plugins-tips">
        如果该框架对你有帮助，那就请作者喝杯饮料吧！加微信号linxin_20探讨问题。
      </div>
      <div>
        <img src="https://lin-xin.gitee.io/images/weixin.jpg" />
      </div>
    </div>
  </div>
</template>

<script>
import { postRequest } from "../../api/index";
import { getRequest } from "../../api/index";
export default {
  name: "test",
  data() {
    return {
      test: "就是一个测试页面",
      natures: [],
      colleges: [],
      query: {
        pageSize: 5,
        pageIndex: 1,
        total_pages: 2
      }
    };
  },
  created() {
    console.log("请求之前group_id", this.query.total_pages);
    this.getAll();
    this.parseUrl();
  },
  methods: {
    // 获取 全部课程类型
    getNatures() {
      getRequest("/course/getnature").then(res => {
        console.log(res);
        this.natures = res.data;
      });
    },
    // 获取 全部学院信息
    getColleges() {
      getRequest("/college/getall").then(res => {
        console.log(res);
        this.colleges = res.data;
      });
    },
    getAll() {
      var res = getRequest("/course/getall", {
        itemsofpage: this.query.pageSize,
        current_page: this.query.pageIndex
      }).then(res => {
        this.query.total_pages = res.data.total_pages;
      });
      return res;
    },
    async parseUrl() {
      let res = await this.getAll();
      var group_id = this.query.total_pages;
      console.log("请求之后group_id:", group_id);
    }
  }
};
</script>

<style></style>
